package com.company.service.impl;

import com.company.service.BaseService;
import com.company.service.StartService;
import com.company.utils.ServiceFactory;

import java.util.Scanner;

public class StartServiceImpl implements StartService {
    @Override
    public void execute() {
        Scanner input = new Scanner(System.in);
        System.out.println("欢迎使用书虫阅读器");
        while (true) {
            System.out.println("---------------------------");
            System.out.println("1.登录");
            System.out.println("2.注册");
            System.out.println("3.退出");
            System.out.println("---------------------------");
            System.out.print("请选择: ");
            switch (input.nextInt()) {
                case 1:
                    BaseService baseService1 = ServiceFactory.getService("login");
                    baseService1.execute();

                    continue;
                case 2:
                    BaseService baseService = ServiceFactory.getService("regist");
                    baseService.execute();
                    continue;
                case 3:
                    System.out.println("退出系统");
                    System.out.println("谢谢使用!");
                    return;
                default:
                    System.out.println("输入有误,请重新输入!");
                    continue;
            }
        }
    }
}
